{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%autoawait asyncio"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from autobahn.asyncio.component import Component, run\n",
    "from autobahn.wamp.types import RegisterOptions\n",
    "\n",
    "import asyncio\n",
    "\n",
    "\n",
    "component = Component(\n",
    "    transports=[\n",
    "        {\n",
    "            \"type\": \"websocket\",\n",
    "            \"url\": \"ws://localhost:8080/ws\",\n",
    "            #\"url\": \"ws://crossbar:8080/ws\",\n",
    "            \"endpoint\": {\n",
    "                \"type\": \"tcp\",\n",
    "                \"host\": \"localhost\",\n",
    "                #\"host\": \"crossbar\",\n",
    "                \"port\": 8080\n",
    "            }\n",
    "        },\n",
    "    ],\n",
    "    realm=\"realm1\",\n",
    ")\n",
    "\n",
    "scratch = {'session': None}\n",
    "\n",
    "@component.on_join\n",
    "async def join(session, details):\n",
    "    print(\"joined {}\".format(details))\n",
    "    scratch['session'] = session\n",
    "    while True:\n",
    "        res = await session.call('foobar.add3', 2, 3)\n",
    "        print(res)\n",
    "        await asyncio.sleep(1)\n",
    "\n",
    "# await run([component])\n",
    "\n",
    "await component.start()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "await scratch['session'].call('foobar.add3', 2, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import cfxdb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "os.listdir(\".testdb\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import seaborn as sns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "print('Python {}'.format(sys.version))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
